﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using KerriganDataContract.DrivingMode;
using KerriganDataContract.Agency;
using KerriganDataContract.Intructor;
using KerriganDataContract.Formation;
using System.ComponentModel;
using KerriganDataContract.Vehicule;

namespace KerriganDataContract.Session
{
    [DataContract]
    public class SessionDC : INotifyPropertyChanged
    {

        private Int32 _Id;
        private DateTime _Date;
        private FormationCategoryDC _FormationCategoryDC;
        private LevelSessionDC _LevelSession;
        private AgencyDC _Agency;
        private InstructorDC _Instructor;
        private FormationDC _Formation;
        private VehicleDC _Vehicle;
        private DateTime _EndDate;

        [DataMember]
        public Int32 Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                this._Id = value;
                OnPropertyChanged("Id");
            }
        }

        [DataMember]
        public DateTime Date
        {
            get
            {
                return this._Date;
            }
            set
            {
                if (value == null)
                {
                    throw new ApplicationException("Start date is mandatory.");
                }
                else
                {
                    this._Date = value;
                    OnPropertyChanged("Date");
                }
            }
        }

        [DataMember]
        public FormationCategoryDC FormationCategoryDC
        {
            get
            {
                return this._FormationCategoryDC;
            }
            set
            {
                this._FormationCategoryDC = value;
                OnPropertyChanged("FormationCategory");
            }
        }

        [DataMember]
        public LevelSessionDC LevelSession
        {
            get
            {
                return this._LevelSession;
            }
            set
            {
                this._LevelSession = value;
                OnPropertyChanged("LevelSession");
            }
        }

        [DataMember]
        public AgencyDC Agency
        {
            get
            {
                return this._Agency;
            }
            set
            {
                this._Agency = value;
                OnPropertyChanged("Agency");
            }
        }

        [DataMember]
        public InstructorDC Instructor
        {
            get
            {
                return this._Instructor;
            }
            set
            {
                this._Instructor = value;
                OnPropertyChanged("Instructor");
            }
        }

        [DataMember]
        public FormationDC Formation 
        {
            get
            {
                return this._Formation;
            }
            set
            {
                this._Formation = value;
                OnPropertyChanged("Formation");
            }
        }

        [DataMember]
        public VehicleDC Vehicle
        {
            get
            {
                return this._Vehicle;
            }
            set
            {
                this._Vehicle = value;
                OnPropertyChanged("Vehicle");
            }
        }

        [DataMember]
        public DateTime EndDate
        {
            get
            {
                return this._EndDate;
            }
            set
            {
                if (value == null)
                {
                    throw new ApplicationException("End date is mandatory.");
                }
                else
                {
                    this._EndDate = value;
                    OnPropertyChanged("EndDate");
                }
                
            }
        }

            

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

    }


}
